package com.wxyzz.canteencommon.common;

/**
 * --- 加油，努力 ---
 *
 * @Author XYP
 * @Date 2024/10/6
 * @Solgne 从想做到能做
 * @Desc
 */
public class R {
    private Integer code;
    private String msg;
    private Object data;

    public static R ok (Object data) {
        return new R(200, "成功", data);
    }

    public static R ok () {
        return new R(200, "成功");
    }

    public static R fail () {
        return new R(500,"失败");
    }

    public static R fail (String msg) {
        return new R(500, msg);
    }

    public static R fail (Integer code,String msg) {
        return new R(code, msg);
    }

    public R() {
    }

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 获取
     * @return code
     */
    public Integer getCode() {
        return code;
    }

    /**
     * 设置
     * @param code
     */
    public void setCode(Integer code) {
        this.code = code;
    }

    /**
     * 获取
     * @return msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * 设置
     * @param msg
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 获取
     * @return data
     */
    public Object getData() {
        return data;
    }

    /**
     * 设置
     * @param data
     */
    public void setData(Object data) {
        this.data = data;
    }

    public String toString() {
        return "R{code = " + code + ", msg = " + msg + ", data = " + data + "}";
    }
}
